import React, { Component } from 'react'
import { NavBar } from "antd-mobile";
import { Cartlist } from '../../http/api';
import Shoplist from './shoplist/shoplist';

export default class shop extends Component {
    constructor() {
        super()
        this.state = {
            shoplist: []
        }
    }
    async componentDidMount() {
        let res = await Cartlist({
            uid: JSON.parse(sessionStorage.getItem("info")).uid
        });
        console.log(res.data.list[0].content)
        let arr1 = res.data.list[0].content?res.data.list[0].content:[]
        let arr2 = res.data.list[1].content?res.data.list[1].content:[]
        let arr = arr1.concat(arr2);
        this.setState({
            shoplist: arr ? arr : []
        })

    }
    render() {
        let { shoplist } = this.state
        return (
            <div>
                <NavBar>购物车</NavBar>
                {shoplist.length > 0 ? <Shoplist shoplist={shoplist}></Shoplist> : null}
            </div>
        )
    }
}
